package sis.reporttest;/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-07-21 15:45
 * @notify
 * @version 1.0
 */

import junit.framework.TestCase;
import sis.report.CourseReport;
import sis.report.RosterReporter;
import sis.studentinfo.Course;
import sis.studentinfo.CourseSession;
import sis.studentinfo.Session;


import java.sql.Array;
import java.sql.Connection;
import java.util.*;

public class CourseReporTest extends TestCase {
    public void testReport() {
        Date date = new Date();
        CourseReport report = new CourseReport();
        report.add(create("ENGL", "101", date));
        report.add(create("CZEC", "200", date));
        report.add(create("CZEC", "100", date));
        report.add(create("ITAL", "410", date));
        assertEquals("CZEC 100" + RosterReporter.NEWLINE +"CZEC 200" + RosterReporter.NEWLINE + "ENGL 101" + RosterReporter.NEWLINE + "ITAL 410" + RosterReporter.NEWLINE, report.text());
    }

    private Session create(String name, String number, Date date){
        return CourseSession.create(new Course(name,number),date);
    }
    public void testSortStringsInPlace() {
        ArrayList<String> list = new ArrayList<>();
        list.add("C");
        list.add("D");
        list.add("B");
        list.add("A");
        ArrayList<String> list2 = new ArrayList<>(list);
        Collections.sort(list2);
        assertEquals("A", list2.get(0));
    }

    public void testStringCompareTo() {
        assertTrue("A".compareTo("B") < 0);
        assertEquals(0, "A".compareTo("A"));
        assertTrue("B".compareTo("A") > 0);
    }

}
